package com.itheima.d06_collection_contains;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 目标：掌握集合的嵌套的书写形式
 */
public class Test {

    public static void main(String[] args) {
        //1.存储省份和其包含的城市信息
        //  一一对应的数据：省份----城市列表，选择Map集合HashMap
        //  HashMap<String  ,  List<String>>
        Map<String, List<String>>  cities = new HashMap<>();

        //2.存储数据
        String province1 = "江苏";
        List<String> city1 = List.of("南京","苏州","无锡");
        cities.put(province1,city1);

        String province2 = "山东";
        List<String> city2 = List.of("济南","青岛","烟台");
        cities.put(province2,city2);

        //3.遍历：键值对
        /*Set<Map.Entry<String, List<String>>> entries = cities.entrySet();

        for (Map.Entry<String, List<String>> entry : entries) {
            String key = entry.getKey();
            List<String> value = entry.getValue();
            System.out.println(key+"------>"+value);
        }*/

        //4.遍历：lambda
        cities.forEach((k,v)-> System.out.println(k+"------>"+v));


    }
}















